package com.basics.channel.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.basics.channel.entity.CyChannelGroupPermission;
import com.basics.channel.mapper.CyChannelGroupPermissionMapper;
import com.basics.channel.service.CyChannelGroupPermissionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 频道分组权限 服务实现类
 * </p>
 *
 * @author WangWei
 * @since 2025-03-09
 */
@Service
public class CyChannelGroupPermissionServiceImpl extends ServiceImpl<CyChannelGroupPermissionMapper, CyChannelGroupPermission> implements CyChannelGroupPermissionService {

    @Override
    public List<String> selectByGroupId(String groupId){
        List<CyChannelGroupPermission> list = list(new QueryWrapper<CyChannelGroupPermission>().eq("group_id",groupId).eq("del_flag",0));
        List<String> resultList = new ArrayList<>();
        if(CollectionUtils.isNotEmpty(list)){
            list.forEach(v->{
                resultList.add(v.getPermission());
            });
        }
        return resultList;
    }
}
